function parents(data, parent_id, parent_field, id_field, results) {
  const res = data.find((i) => {
    return i[id_field] === parent_id
  })
  if (res) {
    results.push(res)
    return parents(data, res[parent_field], parent_field, id_field, results)
  } else {
    return results
  }
}

export default function get_parents(parent_id, data, parent_field, id_field) {
  return parents(data, parent_id, parent_field, id_field, []).reverse()
}
